package com.code.qgjx.tools;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
public class EmailUtil {
    
    @Autowired
    private JavaMailSender mailSender;

    /**
     * 异步发送简单文本邮件
     * @param to 收件人
     * @param subject 主题
     * @param content 内容
     */
    @Async("emailExecutor")
    public void sendSimpleMail(String to, String subject, String content) {
        try {
            SimpleMailMessage message = new SimpleMailMessage();
            message.setTo(to);
            message.setSubject(subject);
            message.setText(content);
            message.setFrom("1132260113@qq.com");
            mailSender.send(message);
        } catch (Exception e) {
            // 异步发送邮件失败不影响主流程
        }
    }
} 